"use client"

import { lazy } from "react"
import { Navigate } from "react-router-dom"

// 使用React.lazy实现组件懒加载
const Login = lazy(() => import("../pages/Login"))
const Dashboard = lazy(() => import("../pages/Dashboard"))
const CustomerManagement = lazy(() => import("../pages/CustomerManagement"))
const EventManagement = lazy(() => import("../pages/EventManagement"))
const StaffManagement = lazy(() => import("../pages/StaffManagement"))
const Settings = lazy(() => import("../pages/Settings"))
const MainLayout = lazy(() => import("../components/Layout/MainLayout"))

// 定义路由配置
const routes = [
  {
    path: "/login",
    element: <Login />
  },
  {
    path: "/",
    element: <MainLayout />,
    children: [
      {
        index: true,
        element: <Dashboard />
      },
      {
        path: "customers",
        element: <CustomerManagement />
      },
      {
        path: "events",
        element: <EventManagement />
      },
      {
        path: "staff",
        element: <StaffManagement />
      },
      {
        path: "settings",
        element: <Settings />
      }
    ]
  },
  {
    path: "*",
    element: <Navigate to="/login" />
  }
]

export default routes